//
//  ViewController.m
//  01-CALayer基本使用
//
//  Created by J on 16/2/20.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *redView;
@property (weak, nonatomic) IBOutlet UIImageView *imgView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    


}
- (IBAction)btn:(UIButton *)sender {
    
    
    
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
    rotationAnimation.duration = 0.8;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 0;
    
    [sender.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //图层形变

    //缩放
    [UIView animateWithDuration:1.0 animations:^{
//
//        _imgView.layer.transform = CATransform3DMakeRotation(M_PI, 1, 1, 0);
//        _imgView.layer.transform = CATransform3DMakeScale(0.5, 0.5, 1);
//        [_imgView.layer setValue:@M_PI forKeyPath:@"transform.rotation.y"];
//        _imgView.layer.transform = CATransform3DIdentity;
    
//        
//        CABasicAnimation* rotationAnimation;
//        rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
//        rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
//        rotationAnimation.duration = 0.8;
//        rotationAnimation.cumulative = YES;
//        rotationAnimation.repeatCount = 0;
//        
//        [_imgView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

    }];
}

- (void)imgViewLayer{
    //cornerRadius默认设置主层边框
    _imgView.layer.cornerRadius = 50;
    _imgView.layer.masksToBounds = YES;//把超出主层边框的内容全部裁剪掉
    NSLog(@"%@",_imgView.layer.contents);
    
    //边框
    _imgView.layer.borderWidth = 10;
    _imgView.layer.borderColor = [UIColor orangeColor].CGColor;
    
  
}

- (void)viewLayer{
    
    //设置阴影 shadowOpacity不透明度
    _redView.layer.shadowOpacity = 1;
    //    _redView.layer.shadowOffset = CGSizeMake(10, 10);
    _redView.layer.shadowColor = [UIColor orangeColor].CGColor;//阴影颜色
    _redView.layer.shadowRadius = 10;
    
    //圆角半径
    _redView.layer.cornerRadius = 50;
    
    //边框
    _redView.layer.borderWidth = 1;
    _redView.layer.borderColor = [UIColor whiteColor].CGColor;
    

    
    
}


@end
